<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8">
<title>门店列表</title>
<link rel="stylesheet" type="text/css" href="/css/reset.css" />
<link rel="stylesheet" type="text/css"  href="/css/common.css" />
<link rel="stylesheet" type="text/css"  href="/css/thems.css">
<link rel="stylesheet" type="text/css"   href="/css/color.css" />
<link rel="stylesheet" type="text/css"  href="/css/bootStrap.min.css" />

<script type="text/javascript" 
	src="js/jquery-3.2.1.js"></script>
		<script type="text/javascript">
			$(function() {
				//自适应屏幕宽度
				window.onresize = function() {
					location = location
				};

				var main_h = $(window).height();
				$('.hy_list').css('height', main_h - 45 + 'px');

				var search_w = $(window).width() - 40;
				$('.search').css('width', search_w + 'px');
				//$('.list_hy').css('width',search_w+'px');
			});
		</script>
		<!--框架高度设置-->
	</head>

	<body>
		<div id="right_ctn ">
			<div class="right_m ">
				<!--会议列表-->
				<div class="hy_list ">
					<div class="box_t ">
						<span class="name ">型号列表</span>
						<!--当前位置-->
						<div class="position ">
							<span class="glyphicon glyphicon-home "></span>
							<a href=" ">首页</a>
						</div>
						<!--当前位置-->
					</div>
					<!--查询-->
					<form action="house/tostorehouseList" class="navbar-form navbar-left" method="post ">
						<div class="input-group ">
							<input type="text " class="form-control storeid" name="storadeId" id=" " value="" placeholder="请输入仓库编号" />
							<span class="input-group-addon ">
						<span class="glyphicon glyphicon-zoom-in "></span>
							</span>
						</div>
						&nbsp;&nbsp;
						<select class="form-control testselect" name="classifyId">
						<option value="0">请选择货物类型</option>
						</select>
						&nbsp;&nbsp;&nbsp;&nbsp;
						
						<div class="input-group">
							<input type="submit" class="btn btn-primary" name="" id="" value="查询" />
						</div>
					</form>
					<!--添加 start-->
					<shiro:hasPermission name="dept_add">
					<ul class="list-inline">
					<li class="margin-top pull-right">
						<button class="btn btn-primary add" data-toggle="modal" data-target="#modal-add" data-backdrop="static">
							<span class="glyphicon glyphicon-plus"></span>&nbsp;添加
						</button> <!--添加模态框--> <!--添加模态框-->
					</li>
					</ul>
					</shiro:hasPermission>
					<!--添加 end-->
					<!--查询-->
					<div class="space_hx ">&nbsp;</div>
					<!--列表-->
					<table class="col-md-11 table table-hover text-center">
						<tr class="bg-hui ">
							<td>店铺编号</td>
							<td>店铺名字</td>
							<td>店铺城市</td>
							<td>详细地址</td>
							<td>操作</td>							
						</tr>
						<#list store as items>
						<tr>
						<td class="carTypeId">${items.storeId}</td>
						<td class="vehicleBrandName">${items.storeName}</td>
						<td class="carTypeName">
						<#if items.cityName??>
						${items.cityName}
						<#else>
						</#if>
						</td>
						<td class="carModel">${items.detailedAddress}</td>
						<td><span class="glyphicon glyphicon-edit bianji"
							data-toggle="modal"  data-cartypeId="${items.storeId}" data-target=".mymodal" data-backdrop="static"></span>
							&nbsp; <a class="removes" href="javaScript:;"><span
								class="glyphicon glyphicon-remove color-red "></span></a></td>
						</tr>
						</#list>
					</table>
					<!--列表-->
					<!--右边底部-->
					<div class="r_foot ">
					<div class="r_foot_m ">
						<!--分页-->
						<div class="page ">
							<input type="hidden" id="thisPageNo"/>
					
						</div>
						<!--分页-->
					</div>
				</div>
					</form>
					<!--右边底部-->
				</div>
				<!--会议列表-->
			</div>
		</div>
		<!-- 添加模态框-->
		<div id="modal-add" class="modal fade">
			<div class="modal-dialog modal-lg">
				<div class="modal-content">
					<div class="modal-header">
						<button class="close" data-dismiss="modal">&times;</button>
						<!--head-text 标题信息-->
						<h4 class="head-text text-left">添加仓库</h4>
					</div>
					<div class="modal-body">
						<form action="" class="form-horizontal" method="post">
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">仓库名称：</span>
								<div class="col-md-9">
									<input type="text" class="form-control storadeName" name="storadeName" id="" value="" />
								</div>
							</div>
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">仓库地址：</span>
								<div class="col-md-9">
									<input type="text" class="form-control storadeAdress" name="storadeAdress" id="" value="" />
								</div>
							</div>
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">仓库类型：</span>
								<div class="col-md-6">
									<select class="form-control testselect classifyId" name="classifyId">
										<option value="0">请选择货物类型</option>
									
									</select>
								</div>
							</div>
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">管理员：</span>
								<div class="col-md-6">
									<select class="form-control testselect userId" name="userId">
										<option value="0">请选择管理人员</option>
									
									</select>
								</div>
							</div>
						
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">货区数量：</span>
								<div class="col-md-6">
									<input type="text" class="form-control rackCount" name="rackCount" id="" value="" />
								</div>
								<span class="col-md-2 margin-top color-hui2 text-size">1-10</span>
							</div>
						
					</div>
					<div class="modal-footer">
						<button class="btn btn-default" data-dismiss="modal">关闭</button>
						<input type="button" value="保存" class="btn btn-primary addlist"/>
					</div>
					</form>
				</div>
			</div>
		</div>
		<!--模态框-->
		<!-- 修改模态框-->
		<div class="modal fade mymodal">
			<div class="modal-dialog modal-lg">
				<div class="modal-content">
					<div class="modal-header">
						<button class="close" data-dismiss="modal">&times;</button>
						<!--head-text 标题信息-->
						<h4 class="head-text text-left">门店车辆详情</h4>
						<span id="aert"></span>
					</div>
					<div class="modal-body">
						<form action="" class="form-horizontal update" method="post">
						<table class="table table-striped">
						    <thead>
						    <tr style="text-align: center;">
						        <th>汽车编号</th>
						        <th>品牌</th>
						        <th>型号</th>
						        <th>排量</th>
						        <th>所属门店</th>
						        <th>所在门店</th>
						        <th>车辆状态</th>
						    </tr>
						    </thead>
						    <tbody id="tbodys">
						    <tr>
						        <td>001</td>
						        <td>Rammohan </td>
						        <td>Reddy</td>
						        <td>A+</td>
						    </tr>
						    <tr>
						        <td>002</td>
						        <td>Smita</td>
						        <td>Pallod</td>
						        <td>A</td>
						    </tr>
						    <tr>
						        <td>003</td>
						        <td>Rabindranath</td>
						        <td>Sen</td>
						        <td>A+</td>
						    </tr>
						    </tbody>
						</table>
					<div class="modal-footer">
						<button class="btn btn-default" data-dismiss="modal">关闭</button>
						<shiro:hasPermission name="dept_update">
						<input type="button" value="保存" class="btn btn-primary updatelist"/>
						</shiro:hasPermission>
					</div>
					</form>
				</div>
			</div>
		</div>
		<!--模态框-->
		
		<script type="text/javascript " src="/js/jquery-3.2.1.js "></script>
		
	<script type="text/javascript " src="/js/bootstrap.js "></script>
		
		<script type="text/javascript">
			$(function() {
				/* 修改 */
			
				/*添加*/
				$(".bianji").click(function(){
					var storeId= $(this).attr("data-cartypeId");
					$.ajax({
						"url":"/cardetailstable/storeCar",
						"type":"get",
						"data":{"storeId":storeId},
						"dataType":"json",
						success : function(data) {
							$("#tbodys").html("");
							for(var i in  data){
								var states="";
								var carstate=data[0].carState;
								if(carstate==1){
									states="闲置";
								}else if(carstate==2){
									states="租出";
								}else if(carstate==3){
									states="回程";
								}else if(carstate==4){
									states="申请维修";
								}else if(carstate==5){
									states="维修中";
								}else{
									states="闲置";
								}
								$("#tbodys").append(' <tr> <td>'+data[0].carId+'</td> <td>'+data[0].vehicleBrandName+'</td><td>'+data[0].carTypeName+'</td><td>'+data[0].carDisplacement+'</td><td>'+data[0].beStoreName+'</td><td>'+data[0].theName+'</td><td>'+states+'</td> </tr>')
							}
						},
						error:function(data){
							alert("123")
						}
						
					})
				})
				
				 $(".addlist").click(function(){
					var storadeName=$("#modal-add .storadeName").val();
					var userId=$("#modal-add .userId").val();
					var classifyId=$("#modal-add .classifyId").val();   
					var storadeAdress=$("#modal-add .storadeAdress").val();
					var rackCount=$("#modal-add .rackCount").val();
					$.ajax({
						"url" : cxt + "/house/addlists",
						"type" : "get",
						"data" : {
							"storadeName" : storadeName,
							"userId" : userId,
							"classifyId" : classifyId,
							"storadeAdress" : storadeAdress,
							"rackCount" : rackCount
						},
						"dataType" : "json",
						success : function(data) {
							if(data>0){
								window.alert("添加成功");
								location.href=cxt+"/house/tostorehouseList";
							}
							else{
								window.alert("添加失败");
								location.href=cxt+"/house/tostorehouseList";
							}
						}
					})
				}) 
				
				
				$(".updatelist").click(function(){
					
					$.ajax({
						"url" : cxt + "/house/updatelists",
						"type" : "get",
						"data" : 
							$(".update").serialize()
						,
						"dataType" : "json",
						success : function(data) {
							if(data>0){
								window.alert("修改成功");
								location.href=cxt+"/house/tostorehouseList";
							}
							else{
								window.alert("修改失败");
								location.href=cxt+"/house/tostorehouseList";
							}
						}
					})
				})
				
				$(".glyphicon-remove").click(function(){
					var storeid=$(this).parents("tr").find(".storadeId").text();
					$.ajax({
						"url" : cxt + "/house/dellists",
						"type" : "get",
						"data" : {"storadeId":storeid}
						,
						"dataType" : "json",
						success : function(data) {
							if(data>0){
								window.alert("删除成功");
								location.href=cxt+"/house/tostorehouseList";
							}
							else if(data==0){
								window.alert("该仓库还有货物未处理");
								location.href=cxt+"/house/tostorehouseList";
							}
							else{
								window.alert("删除失败");
								location.href=cxt+"/house/tostorehouseList";
							}
						},
						error:function(data){
							window.alert("删除异常");
							location.href=cxt+"/house/tostorehouseList";
						}
					})
				})
			})
		</script>
	</body>
	

</html>